<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: Reductions, visitors and broadcasting</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__TutorialReductionsVisitorsBroadcasting.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Reductions, visitors and broadcasting<div class="ingroups"><a class="el" href="group__DenseMatrixManipulation__chapter.html">Dense matrix and array manipulation</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<p>This page explains <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>'s reductions, visitors and broadcasting and how they are used with <a class="el" href="classEigen_1_1MatrixBase.html">matrices </a> and <a class="el" href="classEigen_1_1ArrayBase.html">arrays </a>.</p>
<h1><a class="anchor" id="TutorialReductionsVisitorsBroadcastingReductions"></a>
Reductions</h1>
<p>In <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>, a reduction is a function taking a matrix or array, and returning a single scalar value. One of the most used reductions is <a class="el" href="classEigen_1_1DenseBase.html#addd7080d5c202795820e361768d0140c">.sum() </a>, returning the sum of all the coefficients inside a given matrix or array.</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::Matrix2d</a> mat;</div>
<div class="line">  mat &lt;&lt; 1, 2,</div>
<div class="line">         3, 4;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.sum():       &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#addd7080d5c202795820e361768d0140c">sum</a>()       &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.prod():      &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#af119d9a4efe5a15cd83c1ccdf01b3a4f">prod</a>()      &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.mean():      &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#a21ac6c0419a72ad7a88ea0bc189017d7">mean</a>()      &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.minCoeff():  &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#a0739f9c868c331031c7810e21838dcb2">minCoeff</a>()  &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.maxCoeff():  &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#a7e6987d106f1cca3ac6ab36d288cc8e1">maxCoeff</a>()  &lt;&lt; endl;</div>
<div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Here is mat.trace():     &quot;</span> &lt;&lt; mat.<a class="code" href="classEigen_1_1MatrixBase.html#a544b609f65eb2bd3e368b3fc2d79479e">trace</a>()     &lt;&lt; endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_a0739f9c868c331031c7810e21838dcb2"><div class="ttname"><a href="classEigen_1_1DenseBase.html#a0739f9c868c331031c7810e21838dcb2">Eigen::DenseBase::minCoeff</a></div><div class="ttdeci">internal::traits&lt; Derived &gt;::Scalar minCoeff() const</div><div class="ttdef"><b>Definition:</b> Redux.h:433</div></div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_a21ac6c0419a72ad7a88ea0bc189017d7"><div class="ttname"><a href="classEigen_1_1DenseBase.html#a21ac6c0419a72ad7a88ea0bc189017d7">Eigen::DenseBase::mean</a></div><div class="ttdeci">Scalar mean() const</div><div class="ttdef"><b>Definition:</b> Redux.h:474</div></div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_a7e6987d106f1cca3ac6ab36d288cc8e1"><div class="ttname"><a href="classEigen_1_1DenseBase.html#a7e6987d106f1cca3ac6ab36d288cc8e1">Eigen::DenseBase::maxCoeff</a></div><div class="ttdeci">internal::traits&lt; Derived &gt;::Scalar maxCoeff() const</div><div class="ttdef"><b>Definition:</b> Redux.h:448</div></div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_addd7080d5c202795820e361768d0140c"><div class="ttname"><a href="classEigen_1_1DenseBase.html#addd7080d5c202795820e361768d0140c">Eigen::DenseBase::sum</a></div><div class="ttdeci">Scalar sum() const</div><div class="ttdef"><b>Definition:</b> Redux.h:461</div></div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_af119d9a4efe5a15cd83c1ccdf01b3a4f"><div class="ttname"><a href="classEigen_1_1DenseBase.html#af119d9a4efe5a15cd83c1ccdf01b3a4f">Eigen::DenseBase::prod</a></div><div class="ttdeci">Scalar prod() const</div><div class="ttdef"><b>Definition:</b> Redux.h:495</div></div>
<div class="ttc" id="aclassEigen_1_1MatrixBase_html_a544b609f65eb2bd3e368b3fc2d79479e"><div class="ttname"><a href="classEigen_1_1MatrixBase.html#a544b609f65eb2bd3e368b3fc2d79479e">Eigen::MatrixBase::trace</a></div><div class="ttdeci">Scalar trace() const</div><div class="ttdef"><b>Definition:</b> Redux.h:510</div></div>
<div class="ttc" id="aclassEigen_1_1Matrix_html"><div class="ttname"><a href="classEigen_1_1Matrix.html">Eigen::Matrix</a></div><div class="ttdoc">The matrix class, also used for vectors and row-vectors.</div><div class="ttdef"><b>Definition:</b> Matrix.h:182</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">Here is mat.sum():       10
Here is mat.prod():      24
Here is mat.mean():      2.5
Here is mat.minCoeff():  1
Here is mat.maxCoeff():  4
Here is mat.trace():     5
</pre> </td></tr>
</table>
<p>The <em>trace</em> of a matrix, as returned by the function <code>trace()</code>, is the sum of the diagonal coefficients and can equivalently be computed <code>a.diagonal().sum()</code>.</p>
<h2><a class="anchor" id="TutorialReductionsVisitorsBroadcastingReductionsNorm"></a>
Norm computations</h2>
<p>The (Euclidean a.k.a. \(\ell^2\)) squared norm of a vector can be obtained <a class="el" href="classEigen_1_1MatrixBase.html#ac8da566526419f9742a6c471bbd87e0a">squaredNorm() </a>. It is equal to the dot product of the vector by itself, and equivalently to the sum of squared absolute values of its coefficients.</p>
<p><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> also provides the <a class="el" href="classEigen_1_1MatrixBase.html#a196c4ec3c8ffdf5bda45d0f617154975">norm() </a> method, which returns the square root of <a class="el" href="classEigen_1_1MatrixBase.html#ac8da566526419f9742a6c471bbd87e0a">squaredNorm() </a>.</p>
<p>These operations can also operate on matrices; in that case, a n-by-p matrix is seen as a vector of size (n*p), so for example the <a class="el" href="classEigen_1_1MatrixBase.html#a196c4ec3c8ffdf5bda45d0f617154975">norm() </a> method returns the "Frobenius" or "Hilbert-Schmidt" norm. We refrain from speaking of the \(\ell^2\) norm of a matrix because that can mean different things.</p>
<p>If you want other coefficient-wise \(\ell^p\) norms, use the <a class="el" href="classEigen_1_1MatrixBase.html#a72586ab059e889e7d2894ff227747e35">lpNorm&lt;p&gt;() </a> method. The template parameter <em>p</em> can take the special value <em>Infinity</em> if you want the \(\ell^\infty\) norm, which is the maximum of the absolute values of the coefficients.</p>
<p>The following example demonstrates these methods.</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::VectorXf</a> v(2);</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> m(2,2), n(2,2);</div>
<div class="line">  </div>
<div class="line">  v &lt;&lt; -1,</div>
<div class="line">       2;</div>
<div class="line">  </div>
<div class="line">  m &lt;&lt; 1,-2,</div>
<div class="line">       -3,4;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;v.squaredNorm() = &quot;</span> &lt;&lt; v.squaredNorm() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;v.norm() = &quot;</span> &lt;&lt; v.norm() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;v.lpNorm&lt;1&gt;() = &quot;</span> &lt;&lt; v.lpNorm&lt;1&gt;() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;v.lpNorm&lt;Infinity&gt;() = &quot;</span> &lt;&lt; v.lpNorm&lt;<a class="code" href="namespaceEigen.html#a7951593b031e13d90223c83d022ce99e">Eigen::Infinity</a>&gt;() &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;m.squaredNorm() = &quot;</span> &lt;&lt; m.squaredNorm() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;m.norm() = &quot;</span> &lt;&lt; m.norm() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;m.lpNorm&lt;1&gt;() = &quot;</span> &lt;&lt; m.lpNorm&lt;1&gt;() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;m.lpNorm&lt;Infinity&gt;() = &quot;</span> &lt;&lt; m.lpNorm&lt;<a class="code" href="namespaceEigen.html#a7951593b031e13d90223c83d022ce99e">Eigen::Infinity</a>&gt;() &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="anamespaceEigen_html_a7951593b031e13d90223c83d022ce99e"><div class="ttname"><a href="namespaceEigen.html#a7951593b031e13d90223c83d022ce99e">Eigen::Infinity</a></div><div class="ttdeci">const int Infinity</div><div class="ttdef"><b>Definition:</b> Constants.h:38</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">v.squaredNorm() = 5
v.norm() = 2.23607
v.lpNorm&lt;1&gt;() = 3
v.lpNorm&lt;Infinity&gt;() = 2

m.squaredNorm() = 30
m.norm() = 5.47723
m.lpNorm&lt;1&gt;() = 10
m.lpNorm&lt;Infinity&gt;() = 4
</pre> </td></tr>
</table>
<p><b>Operator</b> <b>norm:</b> The 1-norm and \(\infty\)-norm <a href="https://en.wikipedia.org/wiki/Operator_norm">matrix operator norms</a> can easily be computed as follows: </p><table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> m(2,2);</div>
<div class="line">  m &lt;&lt; 1,-2,</div>
<div class="line">       -3,4;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;1-norm(m)     = &quot;</span> &lt;&lt; m.cwiseAbs().colwise().sum().maxCoeff()</div>
<div class="line">            &lt;&lt; <span class="stringliteral">&quot; == &quot;</span>             &lt;&lt; m.colwise().lpNorm&lt;1&gt;().maxCoeff() &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;infty-norm(m) = &quot;</span> &lt;&lt; m.cwiseAbs().rowwise().sum().maxCoeff()</div>
<div class="line">            &lt;&lt; <span class="stringliteral">&quot; == &quot;</span>             &lt;&lt; m.rowwise().lpNorm&lt;1&gt;().maxCoeff() &lt;&lt; std::endl;</div>
<div class="line">}</div>
</div><!-- fragment -->  </td><td><pre class="fragment">1-norm(m)     = 6 == 6
infty-norm(m) = 7 == 7
</pre> </td></tr>
</table>
<p>See below for more explanations on the syntax of these expressions.</p>
<h2><a class="anchor" id="TutorialReductionsVisitorsBroadcastingReductionsBool"></a>
Boolean reductions</h2>
<p>The following reductions operate on boolean values:</p><ul>
<li><a class="el" href="classEigen_1_1DenseBase.html#ae42ab60296c120e9f45ce3b44e1761a4">all() </a> returns <b>true</b> if all of the coefficients in a given <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> evaluate to <b>true</b> .</li>
<li><a class="el" href="classEigen_1_1DenseBase.html#abfbf4cb72dd577e62fbe035b1c53e695">any() </a> returns <b>true</b> if at least one of the coefficients in a given <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> evaluates to <b>true</b> .</li>
<li><a class="el" href="classEigen_1_1DenseBase.html#a229be090c665b9bf7d1fcdfd1ab6e0c1">count() </a> returns the number of coefficients in a given <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> that evaluate to <b>true</b>.</li>
</ul>
<p>These are typically used in conjunction with the coefficient-wise comparison and equality operators provided by <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>. For instance, <code>array &gt; 0</code> is an Array of the same size as <code>array</code> , with <b>true</b> at those positions where the corresponding coefficient of <code>array</code> is positive. Thus, <code>(array &gt; 0).<a class="el" href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">all()</a></code> tests whether all coefficients of <code>array</code> are positive. This can be seen in the following example:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Array.html">Eigen::ArrayXXf</a> a(2,2);</div>
<div class="line">  </div>
<div class="line">  a &lt;&lt; 1,2,</div>
<div class="line">       3,4;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 0).all()   = &quot;</span> &lt;&lt; (a &gt; 0).<a class="code" href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">all</a>() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 0).any()   = &quot;</span> &lt;&lt; (a &gt; 0).any() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 0).count() = &quot;</span> &lt;&lt; (a &gt; 0).count() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 2).all()   = &quot;</span> &lt;&lt; (a &gt; 2).<a class="code" href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">all</a>() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 2).any()   = &quot;</span> &lt;&lt; (a &gt; 2).any() &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;(a &gt; 2).count() = &quot;</span> &lt;&lt; (a &gt; 2).count() &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclassEigen_1_1Array_html"><div class="ttname"><a href="classEigen_1_1Array.html">Eigen::Array</a></div><div class="ttdoc">General-purpose arrays with easy API for coefficient-wise operations.</div><div class="ttdef"><b>Definition:</b> Array.h:49</div></div>
<div class="ttc" id="agroup__Core__Module_html_ga4abe6022fbef6cda264ef2947a2be1a9"><div class="ttname"><a href="group__Core__Module.html#ga4abe6022fbef6cda264ef2947a2be1a9">Eigen::placeholders::all</a></div><div class="ttdeci">static const Eigen::internal::all_t all</div><div class="ttdef"><b>Definition:</b> IndexedViewHelper.h:189</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">(a &gt; 0).all()   = 1
(a &gt; 0).any()   = 1
(a &gt; 0).count() = 4

(a &gt; 2).all()   = 0
(a &gt; 2).any()   = 1
(a &gt; 2).count() = 2
</pre> </td></tr>
</table>
<h2><a class="anchor" id="TutorialReductionsVisitorsBroadcastingReductionsUserdefined"></a>
User defined reductions</h2>
<p>TODO</p>
<p>In the meantime you can have a look at the DenseBase::redux() function.</p>
<h1><a class="anchor" id="TutorialReductionsVisitorsBroadcastingVisitors"></a>
Visitors</h1>
<p>Visitors are useful when one wants to obtain the location of a coefficient inside a <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>. The simplest examples are <a class="el" href="classEigen_1_1DenseBase.html#a7e6987d106f1cca3ac6ab36d288cc8e1">maxCoeff(&amp;x,&amp;y) </a> and <a class="el" href="classEigen_1_1DenseBase.html#a0739f9c868c331031c7810e21838dcb2">minCoeff(&amp;x,&amp;y)</a>, which can be used to find the location of the greatest or smallest coefficient in a <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>.</p>
<p>The arguments passed to a visitor are pointers to the variables where the row and column position are to be stored. These variables should be of type <a class="el" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Index </a>, as shown below:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> m(2,2);</div>
<div class="line">  </div>
<div class="line">  m &lt;&lt; 1, 2,</div>
<div class="line">       3, 4;</div>
<div class="line"> </div>
<div class="line">  <span class="comment">//get location of maximum</span></div>
<div class="line">  <a class="code" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Eigen::Index</a> maxRow, maxCol;</div>
<div class="line">  <span class="keywordtype">float</span> max = m.maxCoeff(&amp;maxRow, &amp;maxCol);</div>
<div class="line"> </div>
<div class="line">  <span class="comment">//get location of minimum</span></div>
<div class="line">  <a class="code" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Eigen::Index</a> minRow, minCol;</div>
<div class="line">  <span class="keywordtype">float</span> min = m.minCoeff(&amp;minRow, &amp;minCol);</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Max: &quot;</span> &lt;&lt; max &lt;&lt;  <span class="stringliteral">&quot;, at: &quot;</span> &lt;&lt;</div>
<div class="line">     maxRow &lt;&lt; <span class="stringliteral">&quot;,&quot;</span> &lt;&lt; maxCol &lt;&lt; std::endl;</div>
<div class="line">  std:: cout &lt;&lt; <span class="stringliteral">&quot;Min: &quot;</span> &lt;&lt; min &lt;&lt; <span class="stringliteral">&quot;, at: &quot;</span> &lt;&lt;</div>
<div class="line">     minRow &lt;&lt; <span class="stringliteral">&quot;,&quot;</span> &lt;&lt; minCol &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="anamespaceEigen_html_a62e77e0933482dafde8fe197d9a2cfde"><div class="ttname"><a href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Eigen::Index</a></div><div class="ttdeci">EIGEN_DEFAULT_DENSE_INDEX_TYPE Index</div><div class="ttdoc">The Index type as used for the API.</div><div class="ttdef"><b>Definition:</b> Meta.h:59</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">Max: 4, at: 1,1
Min: 1, at: 0,0
</pre> </td></tr>
</table>
<p>Both functions also return the value of the minimum or maximum coefficient.</p>
<h1><a class="anchor" id="TutorialReductionsVisitorsBroadcastingPartialReductions"></a>
Partial reductions</h1>
<p>Partial reductions are reductions that can operate column- or row-wise on a <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>, applying the reduction operation on each column or row and returning a column or row vector with the corresponding values. Partial reductions are applied with <a class="el" href="classEigen_1_1DenseBase.html#a1c0e1b6067ec1de6cb8799da55aa7d30">colwise() </a> or <a class="el" href="classEigen_1_1DenseBase.html#a6daa3a3156ca0e0722bf78638e1c7f28">rowwise() </a>.</p>
<p>A simple example is obtaining the maximum of the elements in each column in a given matrix, storing the result in a row vector:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> mat(2,4);</div>
<div class="line">  mat &lt;&lt; 1, 2, 6, 9,</div>
<div class="line">         3, 1, 7, 2;</div>
<div class="line">  </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Column&#39;s maximum: &quot;</span> &lt;&lt; std::endl</div>
<div class="line">   &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#a58837c81de446efbdb58da07b73a63c1">colwise</a>().<a class="code" href="classEigen_1_1VectorwiseOp.html#a6646b584db116c1661b5bb56750bd6f6">maxCoeff</a>() &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_a58837c81de446efbdb58da07b73a63c1"><div class="ttname"><a href="classEigen_1_1DenseBase.html#a58837c81de446efbdb58da07b73a63c1">Eigen::DenseBase::colwise</a></div><div class="ttdeci">ConstColwiseReturnType colwise() const</div><div class="ttdef"><b>Definition:</b> DenseBase.h:551</div></div>
<div class="ttc" id="aclassEigen_1_1VectorwiseOp_html_a6646b584db116c1661b5bb56750bd6f6"><div class="ttname"><a href="classEigen_1_1VectorwiseOp.html#a6646b584db116c1661b5bb56750bd6f6">Eigen::VectorwiseOp::maxCoeff</a></div><div class="ttdeci">const MaxCoeffReturnType maxCoeff() const</div><div class="ttdef"><b>Definition:</b> VectorwiseOp.h:396</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">Column's maximum: 
3 2 7 9
</pre> </td></tr>
</table>
<p>The same operation can be performed row-wise:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> mat(2,4);</div>
<div class="line">  mat &lt;&lt; 1, 2, 6, 9,</div>
<div class="line">         3, 1, 7, 2;</div>
<div class="line">  </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Row&#39;s maximum: &quot;</span> &lt;&lt; std::endl</div>
<div class="line">   &lt;&lt; mat.<a class="code" href="classEigen_1_1DenseBase.html#aa1cabd3404528fe8cec4bab43d74bffc">rowwise</a>().<a class="code" href="classEigen_1_1VectorwiseOp.html#a6646b584db116c1661b5bb56750bd6f6">maxCoeff</a>() &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclassEigen_1_1DenseBase_html_aa1cabd3404528fe8cec4bab43d74bffc"><div class="ttname"><a href="classEigen_1_1DenseBase.html#aa1cabd3404528fe8cec4bab43d74bffc">Eigen::DenseBase::rowwise</a></div><div class="ttdeci">ConstRowwiseReturnType rowwise() const</div><div class="ttdef"><b>Definition:</b> DenseBase.h:539</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">Row's maximum: 
9
7
</pre> </td></tr>
</table>
<p><b>Note that column-wise operations return a row vector, while row-wise operations return a column vector.</b></p>
<h2><a class="anchor" id="TutorialReductionsVisitorsBroadcastingPartialReductionsCombined"></a>
Combining partial reductions with other operations</h2>
<p>It is also possible to use the result of a partial reduction to do further processing. Here is another example that finds the column whose sum of elements is the maximum within a matrix. With column-wise partial reductions this can be coded as:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> mat(2,4);</div>
<div class="line">  mat &lt;&lt; 1, 2, 6, 9,</div>
<div class="line">         3, 1, 7, 2;</div>
<div class="line">  </div>
<div class="line">  <a class="code" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Eigen::Index</a>   maxIndex;</div>
<div class="line">  <span class="keywordtype">float</span> maxNorm = mat.<a class="code" href="classEigen_1_1DenseBase.html#a58837c81de446efbdb58da07b73a63c1">colwise</a>().<a class="code" href="classEigen_1_1VectorwiseOp.html#a7030fc687c24d687ed7cd70733ba611c">sum</a>().maxCoeff(&amp;maxIndex);</div>
<div class="line">  </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Maximum sum at position &quot;</span> &lt;&lt; maxIndex &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;The corresponding vector is: &quot;</span> &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; mat.col( maxIndex ) &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;And its sum is is: &quot;</span> &lt;&lt; maxNorm &lt;&lt; std::endl;</div>
<div class="line">}</div>
<div class="ttc" id="aclassEigen_1_1VectorwiseOp_html_a7030fc687c24d687ed7cd70733ba611c"><div class="ttname"><a href="classEigen_1_1VectorwiseOp.html#a7030fc687c24d687ed7cd70733ba611c">Eigen::VectorwiseOp::sum</a></div><div class="ttdeci">const SumReturnType sum() const</div><div class="ttdef"><b>Definition:</b> VectorwiseOp.h:480</div></div>
</div><!-- fragment -->  </td><td><pre class="fragment">Maximum sum at position 2
The corresponding vector is: 
6
7
And its sum is is: 13
</pre> </td></tr>
</table>
<p>The previous example applies the <a class="el" href="classEigen_1_1DenseBase.html#addd7080d5c202795820e361768d0140c">sum() </a> reduction on each column though the <a class="el" href="classEigen_1_1DenseBase.html#a1c0e1b6067ec1de6cb8799da55aa7d30">colwise() </a> visitor, obtaining a new matrix whose size is 1x4.</p>
<p>Therefore, if </p><p class="formulaDsp">
\[ \mbox{m} = \begin{bmatrix} 1 &amp; 2 &amp; 6 &amp; 9 \\ 3 &amp; 1 &amp; 7 &amp; 2 \end{bmatrix} \]
</p>
<p>then</p>
<p class="formulaDsp">
\[ \mbox{m.colwise().sum()} = \begin{bmatrix} 4 &amp; 3 &amp; 13 &amp; 11 \end{bmatrix} \]
</p>
<p>The <a class="el" href="classEigen_1_1DenseBase.html#a7e6987d106f1cca3ac6ab36d288cc8e1">maxCoeff() </a> reduction is finally applied to obtain the column index where the maximum sum is found, which is the column index 2 (third column) in this case.</p>
<h1><a class="anchor" id="TutorialReductionsVisitorsBroadcastingBroadcasting"></a>
Broadcasting</h1>
<p>The concept behind broadcasting is similar to partial reductions, with the difference that broadcasting constructs an expression where a vector (column or row) is interpreted as a matrix by replicating it in one direction.</p>
<p>A simple example is to add a certain column vector to each column in a matrix. This can be accomplished with:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> mat(2,4);</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::VectorXf</a> v(2);</div>
<div class="line">  </div>
<div class="line">  mat &lt;&lt; 1, 2, 6, 9,</div>
<div class="line">         3, 1, 7, 2;</div>
<div class="line">         </div>
<div class="line">  v &lt;&lt; 0,</div>
<div class="line">       1;</div>
<div class="line">       </div>
<div class="line">  <span class="comment">//add v to each column of m</span></div>
<div class="line">  mat.<a class="code" href="classEigen_1_1DenseBase.html#a58837c81de446efbdb58da07b73a63c1">colwise</a>() += v;</div>
<div class="line">  </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Broadcasting result: &quot;</span> &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; mat &lt;&lt; std::endl;</div>
<div class="line">}</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Broadcasting result: 
1 2 6 9
4 2 8 3
</pre> </td></tr>
</table>
<p>We can interpret the instruction <code>mat.colwise() += v</code> in two equivalent ways. It adds the vector <code>v</code> to every column of the matrix. Alternatively, it can be interpreted as repeating the vector <code>v</code> four times to form a four-by-two matrix which is then added to <code>mat:</code> </p><p class="formulaDsp">
\[ \begin{bmatrix} 1 &amp; 2 &amp; 6 &amp; 9 \\ 3 &amp; 1 &amp; 7 &amp; 2 \end{bmatrix} + \begin{bmatrix} 0 &amp; 0 &amp; 0 &amp; 0 \\ 1 &amp; 1 &amp; 1 &amp; 1 \end{bmatrix} = \begin{bmatrix} 1 &amp; 2 &amp; 6 &amp; 9 \\ 4 &amp; 2 &amp; 8 &amp; 3 \end{bmatrix}. \]
</p>
<p> The operators <code>-=</code>, <code>+</code> and <code>-</code> can also be used column-wise and row-wise. On arrays, we can also use the operators <code>*=</code>, <code>/=</code>, <code>*</code> and <code>/</code> to perform coefficient-wise multiplication and division column-wise or row-wise. These operators are not available on matrices because it is not clear what they would do. If you want multiply column 0 of a matrix <code>mat</code> with <code>v(0)</code>, column 1 with <code>v(1)</code>, and so on, then use <code>mat = mat * v.asDiagonal()</code>.</p>
<p>It is important to point out that the vector to be added column-wise or row-wise must be of type Vector, and cannot be a <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a>. If this is not met then you will get compile-time error. This also means that broadcasting operations can only be applied with an object of type Vector, when operating with <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a>. The same applies for the <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> class, where the equivalent for VectorXf is ArrayXf. As always, you should not mix arrays and matrices in the same expression.</p>
<p>To perform the same operation row-wise we can do:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keyword">using namespace </span>std;</div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> mat(2,4);</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::VectorXf</a> v(4);</div>
<div class="line">  </div>
<div class="line">  mat &lt;&lt; 1, 2, 6, 9,</div>
<div class="line">         3, 1, 7, 2;</div>
<div class="line">         </div>
<div class="line">  v &lt;&lt; 0,1,2,3;</div>
<div class="line">       </div>
<div class="line">  <span class="comment">//add v to each row of m</span></div>
<div class="line">  mat.<a class="code" href="classEigen_1_1DenseBase.html#aa1cabd3404528fe8cec4bab43d74bffc">rowwise</a>() += v.transpose();</div>
<div class="line">  </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Broadcasting result: &quot;</span> &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; mat &lt;&lt; std::endl;</div>
<div class="line">}</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Broadcasting result: 
 1  3  8 12
 3  2  9  5
</pre> </td></tr>
</table>
<h2><a class="anchor" id="TutorialReductionsVisitorsBroadcastingBroadcastingCombined"></a>
Combining broadcasting with other operations</h2>
<p>Broadcasting can also be combined with other operations, such as <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> or <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> operations, reductions and partial reductions.</p>
<p>Now that broadcasting, reductions and partial reductions have been introduced, we can dive into a more advanced example that finds the nearest neighbour of a vector <code>v</code> within the columns of matrix <code>m</code>. The Euclidean distance will be used in this example, computing the squared Euclidean distance with the partial reduction named <a class="el" href="classEigen_1_1MatrixBase.html#ac8da566526419f9742a6c471bbd87e0a">squaredNorm() </a>:</p>
<table class="example">
<tr>
<th>Example:</th><th>Output: </th></tr>
<tr>
<td><div class="fragment"><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;Eigen/Dense&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main()</div>
<div class="line">{</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::MatrixXf</a> m(2,4);</div>
<div class="line">  <a class="code" href="classEigen_1_1Matrix.html">Eigen::VectorXf</a> v(2);</div>
<div class="line">  </div>
<div class="line">  m &lt;&lt; 1, 23, 6, 9,</div>
<div class="line">       3, 11, 7, 2;</div>
<div class="line">       </div>
<div class="line">  v &lt;&lt; 2,</div>
<div class="line">       3;</div>
<div class="line"> </div>
<div class="line">  <a class="code" href="namespaceEigen.html#a62e77e0933482dafde8fe197d9a2cfde">Eigen::Index</a> index;</div>
<div class="line">  <span class="comment">// find nearest neighbour</span></div>
<div class="line">  (m.colwise() - v).colwise().squaredNorm().minCoeff(&amp;index);</div>
<div class="line"> </div>
<div class="line">  std::cout &lt;&lt; <span class="stringliteral">&quot;Nearest neighbour is column &quot;</span> &lt;&lt; index &lt;&lt; <span class="stringliteral">&quot;:&quot;</span> &lt;&lt; std::endl;</div>
<div class="line">  std::cout &lt;&lt; m.col(index) &lt;&lt; std::endl;</div>
<div class="line">}</div>
</div><!-- fragment -->  </td><td><pre class="fragment">Nearest neighbour is column 0:
1
3
</pre> </td></tr>
</table>
<p>The line that does the job is </p><div class="fragment"><div class="line">(m.colwise() - v).colwise().squaredNorm().minCoeff(&amp;index);</div>
</div><!-- fragment --><p>We will go step by step to understand what is happening:</p>
<ul>
<li><code>m.colwise() - v</code> is a broadcasting operation, subtracting <code>v</code> from each column in <code>m</code>. The result of this operation is a new matrix whose size is the same as matrix <code>m</code>: <p class="formulaDsp">
\[ \mbox{m.colwise() - v} = \begin{bmatrix} -1 &amp; 21 &amp; 4 &amp; 7 \\ 0 &amp; 8 &amp; 4 &amp; -1 \end{bmatrix} \]
</p>
</li>
<li><code>(m.colwise() - v).colwise().squaredNorm()</code> is a partial reduction, computing the squared norm column-wise. The result of this operation is a row vector where each coefficient is the squared Euclidean distance between each column in <code>m</code> and <code>v</code>: <p class="formulaDsp">
\[ \mbox{(m.colwise() - v).colwise().squaredNorm()} = \begin{bmatrix} 1 &amp; 505 &amp; 32 &amp; 50 \end{bmatrix} \]
</p>
</li>
<li>Finally, <code>minCoeff(&amp;index)</code> is used to obtain the index of the column in <code>m</code> that is closest to <code>v</code> in terms of Euclidean distance. </li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:55 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
